package com.winit.common.util;

import org.slf4j.Logger;
import org.springframework.util.Assert;

/**
 * Beetle自定义的断言工具,用于减少判断用的代码.
 *
 *
 * Created by keel2008 on 16/9/6.
 */
public class BAssert {

    public static void isEmpty(String errorMsg, Logger logger, String... verifyTarget) throws Exception{

        try {
            for (String target :
                    verifyTarget) {
                logger.info("判断参数是否为空,target="+target);
                Assert.hasText(target, errorMsg);
            }
        } catch (Exception e) {
            if (logger != null) logger.error(errorMsg, e);
            throw e;
        }
    }

    public static void isTrue(String errorMsg, boolean isTrue, Logger logger) throws Exception {

        if (!isTrue){
            if (logger != null) logger.error(errorMsg);
            throw new Exception(errorMsg);
        }

    }
}
